/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ez2find.util;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;

/**
 *
 * @author Administrador
 */
public class RequestContext {

    /** Creates a new instance of RequestContext */
    public RequestContext() {
    }

    
    public static Object getAttribute(String name){
        return getRequestContext().get(name);
    }
    
    public static void setAttribute(String name, Object value){
        getRequestContext().put(name, value);
    }
    
    private static Map<String,Object> getRequestContext(){
        return FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
        
    }
    
    
    public static List<String> getAllKeys(){
        ArrayList<String> result=new ArrayList<String>();
        for(Iterator<String>keys=getRequestContext().keySet().iterator(); keys.hasNext();){
            result.add(keys.next());
        }
        return result;
    }
    
}